﻿<visi:VisiPage x:Class="VNet.VisiSuite.VisiCentral.Views.AnalysisView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:c="clr-namespace:VNet.VisiSuite.VisiCentral.Controls"
             xmlns:vm="clr-namespace:VNet.VisiSuite.VisiCentral.ViewModels"
             xmlns:visi="clr-namespace:VNet.VisiSuite.VisiCentral.Controls"
             xmlns:vuc="clr-namespace:VNet.VisiSuite.Controls;assembly=VNet.VisiSuite.Controls"
             xmlns:converter="clr-namespace:VNet.VisiSuite.VisiCentral.Common.Converters"
             xmlns:animation="clr-namespace:VNet.VisiSuite.VisiCentral.Common.Animations"
             xmlns:ig="http://schemas.infragistics.com/xaml"
             DataContext="{DynamicResource AnalysisViewModel}"
             Loaded="VisiPage_Loaded"
             Unloaded="VisiPage_Unloaded"
             mc:Ignorable="d" 
             d:DesignHeight="800" d:DesignWidth="1024">

    <visi:VisiPage.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="../Assets/Styles/AppStyles.xaml"/>
            </ResourceDictionary.MergedDictionaries>

            <vm:AnalysisViewModel x:Key="AnalysisViewModel" />

            <converter:VisibilityItemValueConverter x:Key="visibilityConverter" />

            <!-- from IGAutoSalesDashboard -->
            <Storyboard x:Key="RightPanelExpanded">
                <animation:GridLengthAnimation Storyboard.TargetName="RightPanelColumn" To="400" Duration="00:00:00.6">
                    <!--<DoubleAnimation.EasingFunction>
                        <CircleEase EasingMode="EaseOut" />
                    </DoubleAnimation.EasingFunction>-->
                </animation:GridLengthAnimation>
            </Storyboard>
            <Storyboard x:Key="RightPanelCollapsed">
                <animation:GridLengthAnimation Storyboard.TargetName="RightPanelColumn" To="0" Duration="00:00:00.6">
                    <!--<DoubleAnimation.EasingFunction>
                        <CircleEase EasingMode="EaseOut" />
                    </DoubleAnimation.EasingFunction>-->
                </animation:GridLengthAnimation>
            </Storyboard>

            <SolidColorBrush x:Key="NavigationFocusBackgroundBrush" Color="#43FFFFFF"/>
            <SolidColorBrush x:Key="NavigationBackgroundBrush" Color="#FFE7E7E7"/>
            <SolidColorBrush x:Key="NavigationBorderBrush" Color="#00E7E7E7"/>
            <SolidColorBrush x:Key="NavigationForegroundBrush" Color="#FF3F3F3F"/>

            <Style x:Key="ToggleExpandButtonStyle" TargetType="ToggleButton">
                <Setter Property="Cursor" Value="Hand"/>
                <Setter Property="Foreground" Value="{StaticResource NavigationForegroundBrush}"/>
                <Setter Property="Background" Value="{StaticResource NavigationBackgroundBrush}"/>
                <Setter Property="BorderBrush" Value="{StaticResource NavigationBorderBrush}"/>
                <Setter Property="BorderThickness" Value="1"/>
                <Setter Property="Height" Value="16"/>
                <Setter Property="Width" Value="40"/>
                <Setter Property="BorderThickness" Value="1"/>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="ToggleButton">
                            <Grid>
                                <VisualStateManager.VisualStateGroups>
                                    <VisualStateGroup x:Name="CommonStates">
                                        <VisualStateGroup.Transitions>
                                            <VisualTransition GeneratedDuration="0:0:0.1"/>
                                        </VisualStateGroup.Transitions>
                                        <VisualState x:Name="Normal"/>
                                        <VisualState x:Name="MouseOver">
                                            <Storyboard>
                                                <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="normal" d:IsOptimized="True"/>
                                            </Storyboard>
                                        </VisualState>
                                        <VisualState x:Name="Pressed">
                                            <Storyboard>
                                                <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="normal" d:IsOptimized="True"/>
                                            </Storyboard>
                                        </VisualState>
                                        <VisualState x:Name="Disabled">
                                            <Storyboard>
                                                <DoubleAnimation Duration="0" To="0.3" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="normal" d:IsOptimized="True"/>
                                            </Storyboard>
                                        </VisualState>
                                    </VisualStateGroup>
                                    <VisualStateGroup x:Name="CheckStates">
                                        <VisualState x:Name="Checked">
                                            <Storyboard>
                                                <DoubleAnimation Duration="0:0:0.3" To="0" Storyboard.TargetProperty="Angle" Storyboard.TargetName="symbolRotation" d:IsOptimized="True"/>
                                            </Storyboard>
                                        </VisualState>
                                        <VisualState x:Name="Unchecked">
                                            <Storyboard>
                                                <DoubleAnimation Duration="0:0:0.3" To="180" Storyboard.TargetProperty="Angle" Storyboard.TargetName="symbolRotation" d:IsOptimized="True"/>
                                            </Storyboard>
                                        </VisualState>
                                        <VisualState x:Name="Indeterminate"/>
                                    </VisualStateGroup>
                                    <VisualStateGroup x:Name="FocusStates">
                                        <VisualState x:Name="Focused"/>
                                        <VisualState x:Name="Unfocused"/>
                                    </VisualStateGroup>
                                </VisualStateManager.VisualStateGroups>
                                <Border Grid.Row="2" Grid.ColumnSpan="3" Width="40" Height="20" 
                                Background="{TemplateBinding Background}"
                                BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}"/>
                                <Path x:Name="normal"
	 							HorizontalAlignment="Center"
	 							Width="10"
	 							Stretch="Fill"
	 							Opacity="0.6"
	 							Data="M1,6 C1,6 1,11 1,11 C1,11 7.5,6.3583374 7.5,6.3583374 C7.5,6.3583374 14,11 14,11 C14,11 14,6 14,6 C14,6 7.5,1.3583374 7.5,1.3583374 C7.5,1.3583374 1,6 1,6 z"
	 							Fill="{TemplateBinding Foreground}" UseLayoutRounding="False" VerticalAlignment="Center" Height="7" RenderTransformOrigin="0.5,0.5" >
                                    <Path.RenderTransform>
                                        <!--<CompositeTransform Rotation="180"/>-->
                                        <TransformGroup>
                                            <ScaleTransform />
                                            <SkewTransform />
                                            <RotateTransform x:Name="symbolRotation" Angle="180" />
                                            <TranslateTransform />
                                        </TransformGroup>
                                    </Path.RenderTransform>
                                </Path>
                            </Grid>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
        </ResourceDictionary>
    </visi:VisiPage.Resources>
    <vuc:BusyIndicator IsBusy="{Binding IsBusy}">
        <Grid VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Background="{StaticResource WhiteColor}" Focusable="False" Margin="0,0,0,3">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition x:Name="RightPanelColumn" Width="400" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="*" />
                <RowDefinition Height="42" />
            </Grid.RowDefinitions>

            <!--Header-->
            <DockPanel Grid.Row="0" Grid.Column="0" VerticalAlignment="Center">
                <!--Header-->
                <c:WhiteHeader2Control Grid.Row="0" Title="{Binding PageTitle}" LeftMenuIcons="{Binding TopLeftButtonIcons}" RightMenuIcons="{Binding TopRightButtonIcons}" Margin="0,0,0,5" />
            </DockPanel>

            <!--Body-->
            <Grid Grid.Row="1" Grid.Column="0">
                <Grid.RowDefinitions>
                    <RowDefinition Height="6*" />
                    <RowDefinition Height="4*" />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>

                <DockPanel Grid.Row="0" Grid.Column="0" Margin="12 0 6 0">
                    <StackPanel Orientation="Vertical" DockPanel.Dock="Top" HorizontalAlignment="Center" VerticalAlignment="Top">
                        <StackPanel Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Center">
                            <Label Style="{StaticResource LabelStyle}" Margin="0 0 8 0">Top Downtime:</Label>
                            <ComboBox x:Name="cmbTopDownTimeLeft" SelectedIndex="{Binding TopDowntimeLeft}" MinWidth="125">
                                <ComboBoxItem Content="Hours"/>
                                <ComboBoxItem Content="Incidents"/>
                                <ComboBoxItem Content="Percentage "/>
                            </ComboBox>
                            <Label Style="{StaticResource LabelStyle}" Margin="0 0 8 0">by</Label>
                            <ComboBox x:Name="cmbTopDownTimeByLeft" SelectedIndex="{Binding TopDowntimeLeftBy}" MinWidth="125">
                                <ComboBoxItem Content="Reason"/>
                                <ComboBoxItem Content="Cell"/>
                                <ComboBoxItem Content="Product"/>
                            </ComboBox>
                        </StackPanel>
                    </StackPanel>
                    
                </DockPanel>

                <DockPanel Grid.Row="0" Grid.Column="1" Margin="6 0 12 0">
                    <StackPanel Orientation="Vertical" DockPanel.Dock="Top" HorizontalAlignment="Center" VerticalAlignment="Top">
                        <StackPanel Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Center">
                            <Label Style="{StaticResource LabelStyle}" Margin="0 0 8 0">Top Downtime:</Label>
                            <ComboBox x:Name="cmbTopDownTimeRight" SelectedIndex="{Binding TopDowntimeRight}" MinWidth="125">
                                <ComboBoxItem Content="Hours"/>
                                <ComboBoxItem Content="Incidents"/>
                                <ComboBoxItem Content="Percentage "/>
                            </ComboBox>
                            <Label Style="{StaticResource LabelStyle}" Margin="0 0 8 0">by</Label>
                            <ComboBox x:Name="cmbTopDownTimeByRight" SelectedIndex="{Binding TopDowntimeRightBy}" MinWidth="125">
                                <ComboBoxItem Content="Reason"/>
                                <ComboBoxItem Content="Cell"/>
                                <ComboBoxItem Content="Product"/>
                            </ComboBox>
                        </StackPanel>
                    </StackPanel>
                </DockPanel>

                <DockPanel Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Margin="12 8 12 0">
                    <StackPanel DockPanel.Dock="Top" Orientation="Horizontal" VerticalAlignment="Bottom" HorizontalAlignment="Center">
                        <StackPanel Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Center">
                            <Label Style="{StaticResource LabelStyle}" Margin="0 0 8 0">Top Downtime:</Label>
                            <ComboBox x:Name="cmbTopDownTimeBottom" SelectedIndex="{Binding TopDowntimeBottom}" MinWidth="125">
                                <ComboBoxItem Content="Hours"/>
                                <ComboBoxItem Content="Incidents"/>
                                <ComboBoxItem Content="Percentage "/>
                            </ComboBox>
                            <Label Style="{StaticResource LabelStyle}" Margin="0 0 8 0">by</Label>
                            <ComboBox x:Name="cmbTopDownTimeByBottom" SelectedIndex="{Binding TopDowntimeBottomBy}" MinWidth="125">
                                <ComboBoxItem Content="Day"/>
                                <ComboBoxItem Content="Week"/>
                                <ComboBoxItem Content="Month"/>
                            </ComboBox>
                        </StackPanel>
                    </StackPanel>
                </DockPanel>

            </Grid>

            <!--Footer-->
            <!--Footer-->
            <Border Grid.Row="2" Grid.Column="0">
                <ContentControl Template="{StaticResource FooterTemplate}" Background="White" />
            </Border>

            <Grid x:Name="RightColumnRoot" Grid.Column="1" Margin="12" Grid.RowSpan="3" Grid.Row="0">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>
                <StackPanel Grid.Row="0" Orientation="Vertical">
                    <TextBlock Style="{StaticResource NormalTextBlockBlueStyle}">Select Date Range, What to Show</TextBlock>
                    <StackPanel Orientation="Horizontal">
                        <Label Style="{StaticResource LabelStyle}" Margin="0 0 8 0">From:</Label>
                        <ig:XamDateTimeInput x:Name="txtFrom" InvalidValueBehavior="RevertValue" DropDownButtonDisplayMode="Always" AlwaysValidate="True"
                    Value="{Binding FromDate, Mode=TwoWay}" VerticalAlignment="Center" HorizontalAlignment="Left" MinWidth="125">
                        </ig:XamDateTimeInput>
                        <Label Style="{StaticResource LabelStyle}" Margin="8 0 8 0">To:</Label>
                        <ig:XamDateTimeInput InvalidValueBehavior="RevertValue" DropDownButtonDisplayMode="Always"  AlwaysValidate="True" 
                    Value="{Binding ToDate, Mode=TwoWay}" VerticalAlignment="Center" HorizontalAlignment="Left" MinWidth="125">
                            <ig:XamDateTimeInput.ValueConstraint>
                                <ig:ValueConstraint MinInclusive="{Binding FromDate, Mode=OneWay}" />
                            </ig:XamDateTimeInput.ValueConstraint>
                        </ig:XamDateTimeInput>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal" Margin="0 8 0 0">
                        <Label Style="{StaticResource LabelStyle}" Margin="0 0 8 0">Show:</Label>
                        <ComboBox x:Name="cmbWhatToShow" MinWidth="125" SelectedIndex="{Binding DisplayScrap}">
                            <ComboBoxItem Content="Downtime"/>
                            <ComboBoxItem Content="Scrap"/>
                        </ComboBox>
                    </StackPanel>
                    <CheckBox x:Name="chkSeparateOut" IsChecked="{Binding SeparateOut}" Height="Auto" Content="Separate out Waiting for Operator." Margin="0 8 0 0"/>
                </StackPanel>
                <DockPanel Grid.Row="1" VerticalAlignment="Stretch" Height="Auto">
                    <StackPanel Orientation="Horizontal" DockPanel.Dock="Top" Margin="0 12 0 0" >
                        <CheckBox Foreground="{ StaticResource LightDeepSkyBlueColor }" IsChecked="True" IsThreeState="False" x:Name="selectAllReasonCodes" Content="Select Reasons" Click="selectAllReasonCodes_Click" />
                    </StackPanel>
                    <ig:XamDataTree x:Name="reasonCodesTree" BorderThickness="1" BorderBrush="#FFE7E7E7" Style="{StaticResource XamDataTreeStyle}" DisplayMemberPath="Name" CheckBoxMemberPath="IsChecked" 
                            ItemsSource="{Binding ReasonCodes}" Height="Auto" VerticalAlignment="Stretch"
                            ScrollViewer.HorizontalScrollBarVisibility="Disabled" NodeCheckedChanged="reasonCodesTree_NodeCheckedChanged">
                        <ig:XamDataTree.EditingSettings>
                            <ig:TreeEditingSettings/>
                        </ig:XamDataTree.EditingSettings>
                        <ig:XamDataTree.CheckBoxSettings>
                            <ig:CheckBoxSettings IsCheckBoxThreeState="False" CheckBoxVisibility="Visible" CheckBoxMode="Manual" />
                        </ig:XamDataTree.CheckBoxSettings>
                        <ig:XamDataTree.SelectionSettings>
                            <ig:TreeSelectionSettings NodeSelection="None"/>
                        </ig:XamDataTree.SelectionSettings>
                    </ig:XamDataTree>
                </DockPanel>
                <DockPanel Grid.Row="2" VerticalAlignment="Stretch" Height="Auto">
                    <StackPanel Orientation="Horizontal" DockPanel.Dock="Top" Margin="0 12 0 0">
                        <CheckBox Foreground="{ StaticResource LightDeepSkyBlueColor }" IsChecked="True" IsThreeState="False" x:Name="selectAllCells" Content="Select Cells" Click="selectAllCells_Click"/>
                    </StackPanel>
                    <ig:XamDataTree x:Name="cellsTree" BorderThickness="1" BorderBrush="#FFE7E7E7" Style="{StaticResource XamDataTreeStyle}" DisplayMemberPath="Name" CheckBoxMemberPath="IsChecked" ItemsSource="{Binding Cells}"
                                    NodeCheckedChanged="cellsTree_NodeCheckedChanged">
                        <ig:XamDataTree.EditingSettings>
                            <ig:TreeEditingSettings/>
                        </ig:XamDataTree.EditingSettings>
                        <ig:XamDataTree.CheckBoxSettings>
                            <ig:CheckBoxSettings IsCheckBoxThreeState="False" CheckBoxVisibility="Visible" CheckBoxMode="Manual" />
                        </ig:XamDataTree.CheckBoxSettings>
                        <ig:XamDataTree.SelectionSettings>
                            <ig:TreeSelectionSettings NodeSelection="None"/>
                        </ig:XamDataTree.SelectionSettings>
                    </ig:XamDataTree>
                </DockPanel>
                <DockPanel Grid.Row="3" VerticalAlignment="Stretch" Height="Auto">
                    <StackPanel Orientation="Horizontal" DockPanel.Dock="Top" Margin="0 12 0 0">
                        <CheckBox Foreground="{ StaticResource LightDeepSkyBlueColor }" IsChecked="True" IsThreeState="False" x:Name="selectAllProducts" Content="Select Products" Click="selectAllProducts_Click"/>
                    </StackPanel>
                    <ig:XamDataTree x:Name="productsTree" BorderThickness="1" BorderBrush="#FFE7E7E7" Style="{StaticResource XamDataTreeStyle}" DisplayMemberPath="Name" CheckBoxMemberPath="IsChecked" ItemsSource="{Binding Products}"
                                    NodeCheckedChanged="productsTree_NodeCheckedChanged">
                        <ig:XamDataTree.EditingSettings>
                            <ig:TreeEditingSettings/>
                        </ig:XamDataTree.EditingSettings>
                        <ig:XamDataTree.CheckBoxSettings>
                            <ig:CheckBoxSettings IsCheckBoxThreeState="False" CheckBoxVisibility="Visible" CheckBoxMode="Manual" />
                        </ig:XamDataTree.CheckBoxSettings>
                        <ig:XamDataTree.SelectionSettings>
                            <ig:TreeSelectionSettings NodeSelection="None"/>
                        </ig:XamDataTree.SelectionSettings>
                    </ig:XamDataTree>
                </DockPanel>
                <StackPanel Grid.Row="4" Orientation="Vertical">
                    <StackPanel Orientation="Horizontal" DockPanel.Dock="Top" Margin="0 12 0 0">
                        <CheckBox Foreground="{ StaticResource LightDeepSkyBlueColor }" IsChecked="True" IsThreeState="False" x:Name="selectAllShifts" Content="Select Shifts" Click="selectAllShifts_Click"/>
                    </StackPanel>
                    <ig:XamDataTree x:Name="shiftsTree" BorderThickness="1" BorderBrush="#FFE7E7E7" Style="{StaticResource XamDataTreeStyle}" DisplayMemberPath="Name" CheckBoxMemberPath="IsChecked" ItemsSource="{Binding Shifts}" Height="95" Indentation="10"
                                    NodeCheckedChanged="shiftsTree_NodeCheckedChanged"
                    ScrollViewer.HorizontalScrollBarVisibility="Disabled">
                        <ig:XamDataTree.GlobalNodeLayouts>
                            <ig:NodeLayout
                                        Key="Children"
                                        DisplayMemberPath="Name"
                                        TargetTypeName="Model.TreeNode" 
                                        >
                                <ig:NodeLayout.ItemTemplate>
                                    <DataTemplate>
                                        <TextBlock Text="{Binding Data.FieldName}" Foreground="White"/>
                                    </DataTemplate>
                                </ig:NodeLayout.ItemTemplate>
                            </ig:NodeLayout>
                        </ig:XamDataTree.GlobalNodeLayouts>
                        <ig:XamDataTree.EditingSettings>
                            <ig:TreeEditingSettings/>
                        </ig:XamDataTree.EditingSettings>
                        <ig:XamDataTree.CheckBoxSettings>
                            <ig:CheckBoxSettings IsCheckBoxThreeState="False" CheckBoxVisibility="Visible" CheckBoxMode="Manual" />
                        </ig:XamDataTree.CheckBoxSettings>
                        <ig:XamDataTree.SelectionSettings>
                            <ig:TreeSelectionSettings NodeSelection="None"/>
                        </ig:XamDataTree.SelectionSettings>
                    </ig:XamDataTree>
                </StackPanel>
            </Grid>
            

            <!-- Grid Expansion ToggleButtons -->
            <Grid Grid.Row="0" Grid.RowSpan="3" Grid.Column="0">
                <Rectangle Fill="#FFE7E7E7" 
				Width="3" HorizontalAlignment="Right" VerticalAlignment="Stretch"
				Margin="0,0,0,0" />
                <ToggleButton x:Name="RightPanelToggleButton" 
				Click="RightPanelToggleButtonClick"
				Style="{StaticResource ToggleExpandButtonStyle}"
				Height="Auto" HorizontalAlignment="Right" Width="Auto" 
				RenderTransformOrigin="0.5,0.5" UseLayoutRounding="False" 
				d:LayoutRounding="Auto" VerticalAlignment="Center" 
				Margin="0,0,-5,0"
                              Panel.ZIndex="1">
                    <!--Margin="594,390,-10,390"-->
                    <ToggleButton.RenderTransform>
                        <TransformGroup>
                            <RotateTransform Angle="-90" />
                        </TransformGroup>
                    </ToggleButton.RenderTransform>
                </ToggleButton>
            </Grid>
        </Grid>
    </vuc:BusyIndicator>
</visi:VisiPage>
